/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * CashierFrame.java
 *
 * Created on 2011-12-8, 14:34:53
 */
package mscs.cashier.view;

import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import javax.swing.AbstractAction;
import javax.swing.ActionMap;
import javax.swing.InputMap;
import javax.swing.JComponent;
import javax.swing.JOptionPane;
import javax.swing.KeyStroke;

/**
 *
 * @author Cake
 */
public class CashierFrame extends javax.swing.JFrame {

    /** Creates new form CashierFrame */
    public CashierFrame() {
        initComponents();
        setEnvironment();
    }

   
    
    
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        salePanel1 = new mscs.cashier.view.SalePanel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setName("Form"); // NOI18N
        getContentPane().setLayout(new javax.swing.BoxLayout(getContentPane(), javax.swing.BoxLayout.LINE_AXIS));

        salePanel1.setName("salePanel1"); // NOI18N
        getContentPane().add(salePanel1);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    public void setEnvironment() {
        InputMap inputMap = getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
        inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_S, 0), "SalePanel");//监听S键
        inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_R, 0), "ReturnPanel");
        ActionMap actionMap = getRootPane().getActionMap();
        actionMap.put("SalePanel", new AbstractAction() {
            public void actionPerformed(ActionEvent e) {
                CashierFrame.this.getContentPane().removeAll();
                CashierFrame.this.getContentPane().add(new SalePanel());
                CashierFrame.this.validate();
                CashierFrame.this.getRootPane().grabFocus();
            }
        });
        actionMap.put("ReturnPanel", new AbstractAction() {
            public void actionPerformed(ActionEvent e) {
                 CashierFrame.this.getContentPane().removeAll();
                 CashierFrame.this.getContentPane().add(new ReturnPanel());
                 CashierFrame.this.validate();
                 CashierFrame.this.getRootPane().grabFocus();
            }
        });
    }
   
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private mscs.cashier.view.SalePanel salePanel1;
    // End of variables declaration//GEN-END:variables
}
